package cn.mifengkong.appcommon.webview.jshandler;

import android.content.Context;
import android.text.TextUtils;

import com.mifengkong.frtools.jsbridge.CallBackFunction;
import com.mifengkong.frwidget.titlebar.WebViewTitleBarUIComponent;

import cn.mifengkong.appcommon.webview.listener.JsBridgeCallBackListener;
import cn.mifengkong.appcommon.webview.uicomponent.WebViewUIComponent;

/**
 * @author jiangyongxing
 * @date 2017/10/9
 * 描述：
 */

public class RightBtnJsHandler extends CustomeWebviewTitleHandler {

    public RightBtnJsHandler(Context context, WebViewUIComponent webViewUIComponent, WebViewTitleBarUIComponent titleBarUIComponent, String applicationId, JsBridgeCallBackListener jsBridgeCallBackListener) {
        super(context, webViewUIComponent, titleBarUIComponent, applicationId, jsBridgeCallBackListener);
    }

    @Override
    protected void setImageToView(String iconUrl, String jumpUrl, String text, IvOnclickListener ivOnclickListener) {
        if (!TextUtils.isEmpty(iconUrl)) {
            mWebViewTitleBarUIComponent.setRightImageViewRes(iconUrl, ivOnclickListener);
        } else {
            mWebViewTitleBarUIComponent.setRightContent("", 0);
            mWebViewTitleBarUIComponent.initRightBlack(text, ivOnclickListener);
        }

    }

    @Override
    public void OnHandler(String handlerName, String responseData, CallBackFunction function) {
        parseResponseData(responseData, function);
    }
}
